package ss.pku.jsa.worklist.algorithm;

import java.util.Set;
import java.util.Stack;

import ss.pku.jsa.worklist.WorkListTemplate;
import ss.pku.jsa.worklist.om.Constraint;
import ss.pku.jsa.worklist.om.Expression;
import ss.pku.jsa.worklist.om.Value;

public class LIFOWorkList<M,K> extends WorkListTemplate<M, K> {
	Stack<Constraint<M, K>> stack;

	public LIFOWorkList(Constraint<M, K>[] constraints) {
		super(constraints);
		stack = new Stack<Constraint<M,K>>();
	}

	@Override
	public Set<Value<M,K>> eval(Constraint<M, K> constraint) {
		Expression<M, K> exp = constraint.getRight();
		return exp.evaluate();
	}

	@Override
	public void insert(Constraint<M, K> constraint) {
		stack.push(constraint);
	}

	@Override
	public Constraint<M, K> extract() {
		return stack.pop();
	}

}
